package com.jqh.jetpackdemo;

import android.view.View;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

public class MyViewModelWithLiveData extends ViewModel {
    private MutableLiveData<Integer> likeNumber;

    private MutableLiveData<Integer> isVisable ;

    public MutableLiveData<Integer> getLikeNumber() {
        if (likeNumber == null) {
            likeNumber = new MutableLiveData<>();
            likeNumber.setValue(0);
        }
        return likeNumber;
    }

    public MutableLiveData<Integer> getVisable() {
        if (isVisable == null) {
            isVisable = new MutableLiveData<>();
            isVisable.setValue(View.INVISIBLE);
        }
        return isVisable;
    }

    public void addLikeNumber(int add) {
        isVisable.setValue(View.VISIBLE);
        likeNumber.setValue(likeNumber.getValue() + add);
    }
}
